using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ent.Web.Helper;
using Ent.Voice;
public partial class ActivateFeed : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Activate();
        }
    }
    private void Activate()
    {
        string url = "";
        try
        {
            string voteid = HttpUtility.UrlDecode(Request.QueryString["id"]);
            string ip = HttpUtility.UrlDecode(Request.QueryString["pass"]);
            if (voteid != "" && ip != "" && voteid != null && ip != null)
            {
                ActivationResponse res = Ent.Voice.Nomination.Vote.Activate(voteid, ip);
                switch (res)
                {
                    case ActivationResponse.Activated:
                        url = "Info.aspx?t=3&c=VoteActivated";
                        break;
                    case ActivationResponse.InvalidActivation:
                        url = "Info.aspx?t=2&c=InvalidActivation";
                        break;
                    case ActivationResponse.Error:
                    default:
                        throw new Exception("Invalid activation Request. " + Request.Url.PathAndQuery);
                        break;
                }
            }
            else
                url = "Info.aspx?t=2&c=InvalidActivation";
        }
        catch (Exception exc)
        {
            Common.ErrorPage(exc);
        }
        if (url != "")
            Response.Redirect(url);
    }
}
